package cn.itcast.hotel.controller;


import cn.itcast.hotel.pojo.Hotel;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.pojo.UserBean;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService iHotelService;

    @PostMapping("/list")
    public PageResult queryHotel(@RequestBody RequestParams requestParams){
        return iHotelService.queryHotel(requestParams);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams requestParams){
        return iHotelService.filters(requestParams);
    }

    @GetMapping("/suggestion")
    public List<String> getSuggestion(@RequestParam("key") String prefix){
        return iHotelService.getSuggestion(prefix);
    }

    /**
     * 立即预定
     * @param id
     * @return
     */
    @GetMapping("findHotelById")
    public Object findHotelById(@RequestParam("id")  Long id){
        return iHotelService.findHotelById(id);
    }



}
